#include "common.h"
#include "tmrsys.h"
#include "i2c_IMU.h"
#include "imu.h"
#include "adxl345.h"
#include "l3g4200d.h"
#include "hmc5883l.h"
#include "bmp085.h"
#include "utils/uartstdio.h"
#include "driverlib/systick.h"
#include "driverlib/eeprom.h"
#include "kalman.h"
#include "driverlib/rom.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/fpu.h"


#define I2C_ID_ADXL345      ((uint8_t)0x53) // assumes ADXL345 alternate address pin is grounded
#define I2C_ID_L3G4200D     ((uint8_t)0x69)
#define I2C_ID_HMC5883L     ((uint8_t)0x1E)
#define I2C_ID_BMP085       ((uint8_t)0x77)
#define DELAY_MS(ms)    {ROM_SysCtlDelay(ms * (ROM_SysCtlClockGet() / 3000));} // multiplier for SysCtlGet() store in global variables

#define RED GPIO_PIN_1
#define BLUE GPIO_PIN_2
#define GREEN GPIO_PIN_3
#define on 1
#define off 0
#define LED_INIT()              { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED | GREEN | BLUE);}
#define LED(color,sw)           {HWREG(GPIO_PORTF_BASE +  (color << 2)) = (((color >> 01) << sw) & color);}

#define DEBUG 1
//#define YAW 0
//#define PITCH 0
//#define ROLL 0
#define BLINK 1

void util_FillAveragingBuffers(void);
void ui_SetDefaultUserParams(void);
void ui_ADXL345Calibrate(void);
void ui_HMC5883LCalibrate(void);
void ui_L3GCalibrate(void);
void mcu_Config(void);
void ui_ADXL345Calibrate(void);
void ui_HMC5883LCalibrate(void);
void ui_L3GCalibrate(void);
int util_WaitBtnPressTimeout(int seconds);
void ui_ReadUserParams(void);
int ui_Check_Params(void);
void ui_ReadUserParams(void);
int ui_WriteUserParams(void);
void util_MemCpy(uint8_t* pDestination, uint8_t* pSource, int32_t nBytes);
